<template>
    <div>
    </div>
</template>
<script>
    let wx = require('weixin-js-sdk');
    import XWxConfig from '../../x/XWxConfig'
    import XLocation from '../../x/XLocation'


    export default {
        mounted() {
            let that = this;
            let wxConfig = XWxConfig.getConfig();
            if (wxConfig) {
                wxConfig.jsApiList = ['getLocation'];
                wx.config(wxConfig);
                wx.ready(() => {
                    wx.getLocation({
                        type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
                        success: function (res) {
                            var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                            var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                            var speed = res.speed; // 速度，以米/每秒计
                            var accuracy = res.accuracy; // 位置精度
                            XLocation.updateUserLocation(longitude, latitude)
                            if (window.location.href.includes('/act/circle/')) {
                                that.$store.commit('bowserRecord');
                            }
                            console.log('getLocation')
                            console.log(res)
                        },
                        fail(res) {
                            XLocation.userGetHeSelfLocation();
                            console.log('fail')
                            console.log(res)
                        }
                    })
                });
                wx.error(function (res) {
                    console.log("wx验证失败！")
                });
            }
        }
    }

</script>
<style scoped>

</style>
